<!doctype html>
<html>

<head>
	<meta charset="utf-8">
	<title></title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link rel="stylesheet" type="text/css" href="../../../css/mui.min.css" />
	<link rel="stylesheet" type="text/css" href="../../../css/mescroll.min.css" />
	<link rel="stylesheet" type="text/css" href="../../../css/pages/repairsRecords.css" />
</head>

<body>
	<div id="mescroll" class="mescroll">
		<div id="app" class="content">
			<div class="header-title">报修历史</div>
			<div class="list">
				<div class="list-item" v-for="item in list">
					<div class="item-period">{{item.repCD | time}}</div>
					<div class="item-repairs-list">
						<div class="repairs-item" v-for="son in item.buildingList"  @click="repairDetailsTap(son.repID)">
							<div class="title">
								<span class="icon"></span> 
								<span class="text" v-text="son.repDetails"></span>
							</div>
							<div class="time">{{son.repCD | dateFormat}}</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script src="../../../js/Width.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../../js/mui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../../js/mescroll.min.js"></script>
	<script src="../../../js/vue.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../../js/Util.js" type="text/javascript" charset="utf-8"></script>
	<script src="https://cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js"></script>
	<script type="text/javascript">
		mui.init()
		mui.plusReady(function () {
			if (!mui.os.android) {
				FastClick.attach(document.body);
			}
			ws = plus.webview.currentWebview();
			downCallback() // 请求参数
		})

		var app = new Vue({
			el: "#app",
			data: {
				list: []
			},
			methods: {
				repairDetailsTap: function(repID){
					mui.openWindow({
						url: 'repairDetails.html',
						id: 'repairDetails',
						styles: { // 窗口参数 参考5+规范中的WebviewStyle,也就是说WebviewStyle下的参数都可以在此设置
							titleNView: { // 窗口的标题栏控件
								titleText: "报修详情", // 标题栏文字,当不设置此属性时，默认加载当前页面的标题，并自动更新页面的标题         // 字体颜色,颜色值格式为"#RRGGBB",默认值为"#000000"
								titleSize: "17px", // 字体大小,默认17px
								backgroundColor: "#ffffff", // 控件背景颜色,颜色值格式为"#RRGGBB",默认值为"#F7F7F7"
								autoBackButton: true,
							}
						},
						extras: {
							repID:repID
						},
						waiting: {
							autoShow: false
						}
					})
				}
			},
			filters: {
				time: function (value){
				 var list = value.split("-")
				 return list[0] + '年' + list[1] + '月'
				},
				dateFormat: function (value){
					var list = value.split(" ")
					var _list = list[0].split("-")
					return _list[1] + '月' + _list[2] + '日' + " " + list[1]
				}
			},
		})

		var mescroll = new MeScroll("mescroll", {
			down: {
				auto: false,
				callback: downCallback //下拉刷新的回调
			}
		});

		function downCallback() {
			var userID = Util.getState('$state').userID // 获取用户ID
			mui.post(Util.HTTP+ 'api/Repairs/GetRepairs',{
				userID: userID
			},function(res){
				if(res.code==1001){
					// mui.toast('请求成功')
					mescroll.endSuccess(); //无参
					app.list = res.data
				}else{
					mui.toast(res.message)
					mescroll.endErr();
				}
			})
		}

		function upCallback(page, mescroll) {
			console.log(page)
			setTimeout(function () {
				// mui.toast('刷新成功')
				mescroll.endErr();
			}, 1000)
		}
	</script>
</body>

</html>
